#ifndef STALLPAGE_H
#define STALLPAGE_H

#include <QWidget>
#include <QWidget>
#include<QSqlQuery>
#include<QSqlRecord>
#include<QSqlError>
#include <QDebug>
#include<QMessageBox>
#include <QDateTime>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <ctime>


namespace Ui {
class stallpage;
}

class stallpage : public QWidget
{
    Q_OBJECT

public:
    explicit stallpage(QWidget *parent = nullptr);
    ~stallpage();

    int hourlyRate  = 5; // 每小时
    int freeMinutes = 15; // 前15分钟免费
    double dailyMax = 50.0; // 每天最多50元

    void Qurey();
    int select1(QString carIdValue);
    QString selectin(QString carIdValue);
    QString selectout(QString carIdValue);
    time_t stringToTimeT(QString timeStr);
    double calculateParkingFee(QString In_time, QString Out_time,  double hourlyRate, int freeMinutes, double dailyMax);
    bool hasDuplicateCarids(const QString &carid);
    int insert_carid(QString carIdValue);
    int add_nonstall();
    void insert_num(QString str);
    void In_stall(QString carid);
    void Out_stall(QString carid);
signals:
    void sendMsg(double cost);
    void parking_fee(double cost);

private slots:
    void on_btn_add_clicked();
    void on_btn_del_clicked();
    void on_btn_addstall_clicked();
    void on_bth_delstall_clicked();

private:
    Ui::stallpage *ui;
};

#endif // STALLPAGE_H
